package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    @Insert("insert into user(username, password,nickname) values(#{username}, #{password},#{username})")
    Integer insertUser(User user);

    @Delete("delete from user where username=#{username}")
    Integer deleteUser(@Param("username") String username);

    @Update("update user set password=#{password} where username=#{username}")
    Integer updateUser(User user);//修改用户密码

    @Update("update user set picture=#{picture},nickname=#{nickname},sex=#{sex},province=#{province},city=#{city},introduction=#{introduction} where username=#{username}")
    Integer updateModify(User user);//修改个人信息

    @Select("select * from user where username=#{username}")
    User selectByUsername(@Param("username") String username);

    @Select("select password from user where username=#{username}")
    User selectPwd(@Param("username") String username);//通过用户名查找密码

    @Select("select username,nickname,sex,province,city,introduction,picture from user where username=#{username}")
    User selectALL(String username);//获取个人信息

    @Select("select count(*) from notesNumber where username=#{username}")
    Integer selectNotesNum(String username);//获取笔记数

}
